package com.hxd.charitysystem.adapter

import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import com.hxd.charitysystem.R
import com.hxd.charitysystem.image.ImageLoader
import com.hxd.charitysystem.utils.ProjectUrl


/**
 *  项目名：    CharitySystem
 *  包名：      com.hxd.charitysystem.adapter
 *  文件名:     DetailsImageAdapter
 *  创建者:     HXD
 *  创建时间:   2019/5/5 21:37
 *  描述:       展示图片的adapter
 */
 class DetailsImageAdapter(val data:ArrayList<String>) : RecyclerView.Adapter<DetailsImageAdapter.ViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_details_image,parent,false)
        return  ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return data.size
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        ImageLoader.loadImage(holder.image, ProjectUrl.getUserImage + data[position])
    }

    /**
     * RecyclerView的持有者类
     */
    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var image: ImageView = view.findViewById(R.id.image)
    }
}